﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DA
{
    public class KhuonDA:BaseConnection
    {
         public SqlDataAdapter danhSachKhuonAdapter { set; get; }
         public KhuonDA()
         {
          
         }
         public DataSet timKiemKhuon(string maKhuon)
         {
             DataSet ds = new DataSet();
             String sqlStatement = "";
             sqlStatement = "SELECT MaKhuon, TenKhuon, DienGiai, SoLuong, SoLuongDangSuDung, HinhAnh, KichThuoc, GhiChu";
             sqlStatement += " FROM Khuon";
             sqlStatement += " WHERE MaKhuon = '" + maKhuon + "'";

             openConnect();

             SqlCommand cmd = new SqlCommand(sqlStatement, con);
             danhSachKhuonAdapter = new SqlDataAdapter(cmd);
             danhSachKhuonAdapter.SelectCommand = cmd;
             SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(danhSachKhuonAdapter);
             danhSachKhuonAdapter.Fill(ds, "Khuon");
             closeConnect();
             return ds;        
         }

         public DataSet layDanhSachKhuon()
         {
             openConnect();
             String sqlStm = "SELECT * FROM Khuon";

             SqlCommand cmd = new SqlCommand(sqlStm, con);
             danhSachKhuonAdapter = new SqlDataAdapter(cmd);
             danhSachKhuonAdapter.SelectCommand = cmd;
             SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(danhSachKhuonAdapter);
             DataSet ds = new DataSet();
             danhSachKhuonAdapter.Fill(ds, "Khuon");
             closeConnect();
             return ds;   
         }
        
    }
}
